<!--suppress ALL -->
<script src="/static/js/amazeui.datatables.min.js"></script>
<script src="/static/js/dataTables.responsive.min.js"></script>
<script src="/static/js/amazeui.page.js"></script>
<script src="/static/js/layer/layer.js"></script>
<!--<script src="/static/js/app.js"></script>-->
<!--<script src="/static/js/echarts.min.js"></script>-->
<script>
    var limit = {{.limit}};
    if ({{.total}} =='1')
    {
        sendajaxdata(limit, 0);
    }
    function sendajaxdata(limit, offset) {
        var progress = $.AMUI.progress;
        progress.start();
        offset = limit * (offset - 1 );

        var html = [];
        $.get("/nodejson?limit=" + limit + "&offset=" + offset, function (data) {
            for (var i = 0; i < data.length; i++) {
                html += '<tr class="gradeX">';
                html += '<td>' + data[i].Name + '</td>';
                html += '<td>' + data[i].Id + '</td>';
                html += '<td>' + data[i].Value + '</td>';
                html += '<td>';
                html += '<div class="tpl-table-black-operation">';
                html += '<a href="javascript:editorNode('+ data[i].Id +');">';
                html += '<i class="am-icon-pencil"></i> 编辑 </a>';
                html += '<a href="javascript:deleteNode('+ data[i].Id +');" class="tpl-table-black-operation-del">';
                html += '<i class="am-icon-trash"></i> 删除';
                html += '</a>';
                html += '</div>';
                html += '</td>';
                html += '</tr>';
            }
            $('#nodelist').html(html);
            progress.done();
        });
    }

    showPage({{.total}});

    function editorNode(id) {
        $("#NodeId").val(id);

        console.log($("#NodeId").val());

        layer.open({
            type: 2,
            title: '修改权限',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            content: '/nodemodal',
        });
    }

    function deleteNode() {

    }

    $('.create_node').on('click', function () {
        layer.open({
            type: 2,
            title: '创建Node',
            shadeClose: true, //点击遮罩关闭层
            area: ['900px', '700px'],
            content: '/nodemodal',
        });
    });

    $('.create_controller').on('click', function () {
        layer.open({
            type: 2,
            title: '',
            shadeClose: true, //点击遮罩关闭层
            area: ['900px', '700px'],
            content: '/nodecontrollermodal',
        });
    });

    $(".moduleCreate").on("click", function () {
        layer.open({
            type: 2,
            title: 'iframe父子操作',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            content: '/moduleModal'
        });
    });

    $("#modelModal").on("click", function() {
        layer.open({
            type: 2,
            title: '新建model',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            content: '/modelModal'
        });
    });

    $("#UpdateModal").on("click", function() {
        layer.open({
            type: 2,
            title: '表结构修改',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            content: '/updateDB'
        });
    });

    $("#Controller").on("click", function () {
        layer.open({
            type: 2,
            title: '表结构修改',
            maxmin: true,
            shadeClose: true, //点击遮罩关闭层
            area : ['800px' , '520px'],
            content: '/nodemodal/tocontroller'
        });
    });

</script>